#include <fwLog.h>
#include <Game\fwStateManager.h>
#include "../Header/Game.h"
#include "../Header/Entity/Image2D.h"
#include "../Header/State/Logo.h"
//#include "../Header/AppCore/StateManager.h"

Game* Game::m_instance = NULL;

Game* Game::GetInstance()
{
	if (!m_instance)
		m_instance = new Game();
	return m_instance;
}

void Game::DestroyInstance()
{
	LOGI("Game destroy\n");
	SAFE_DEL(m_instance);
}

int Game::Init()
{
	LOGI("Init game data:\n");
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	StateManager::GetInstance()->Resize(1);
	State * temp = new Logo();
	temp->szName = "Logo";
	StateManager::GetInstance()->Switch(temp);
	StateManager::GetInstance()->ExternalSwitch();
	return 0;
}

void Game::Destroy()
{
	LOGI("Destroy game data:\n");
	StateManager::GetInstance()->Destroy();
	StateManager::DestroyInstance();
	//SAFE_DEL(entity);
}

void Game::Update(float deltaTime)
{
	StateManager::GetInstance()->GetCurrentState()->Update(deltaTime);
}

void Game::Draw()
{
	glClear(GL_COLOR_BUFFER_BIT);
	StateManager::GetInstance()->GetCurrentState()->Draw();
}